class Solution(object):
    def maxProfit(self, prices, fee):
        """
        :type prices: List[int]
        :type fee: int
        :rtype: int
        """
        l = len(prices)
        #0，拥有股票，1卖出股票
        dp0 = -prices[0]
        dp1 = 0

        for i in range(1, l):
            tmp = max(dp1-prices[i], dp0)
            dp1 = max(dp0 + prices[i] - fee, dp1)
            dp0 = tmp
        return dp1
